<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>AdminLTE 2 | Simple Tables</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="/bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="/bower_components/Ionicons/css/ionicons.min.css">
  <!-- DataTables -->
  <link rel="stylesheet" href="/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="/dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="/dist/css/skins/_all-skins.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <!--头部-->
  <header id="headerDiv" class="main-header">
    <!--#include  file="/pages/header.html"-->
  </header>

  <!--左侧边栏 -->
  <aside id="sidebarDiv" class="main-sidebar">
    <!--#include  file="/pages/sidebar.html"-->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Simple Tables
        <small>preview of simple tables</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Tables</a></li>
        <li class="active">Simple</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">

      <!-- /.row -->
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">分页列表demo</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
              <table id="datatable" class="table table-bordered table-hover">
                <thead>
                <tr>
                  <th>ID</th>
                  <th>User</th>
                  <th>Date</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <!--底部-->
  <footer id="footerDiv" class="main-footer">
    <!--#include  file="/pages/footer.html"-->
  </footer>

  <!-- Control Sidebar -->
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->
<!-- jQuery 3 -->
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/morris.js/morris.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- Slimscroll -->
<script src="/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="/dist/js/adminlte.min.js"></script>

<script>
    $(function () {
        var datatable = $("#datatable").DataTable({
            // 'scrollX' : $(document).width(),
            'aLengthMenu' : [2, 20, 250, 500],
            'scrollCollapse' : true,//
            'stateSave' : false,//保存配置状态
            'processing' : true, // 显示loading
            'paging' : true,
            'lengthChange' : true,
            'searching' : false,// 取消搜索框
            'ordering' : false,// 取消字段排序
            'info' : true,
            'autoWidth' : false,
            'deferRender': true,
            'serverSide' : true, // ajax请求时必须写本项
            // 'pagingType' : 'full_numbers',
            'ajax' : { // ajax请求
                'type' : "POST",
                'url' : "/lmgame/data/getData",
                'data' : function ( d ) {
                    return d;
                },
                "error": function(xhr, ts, et) { //XMLHttpRequest, textStatus, errorThrown
                    if(xhr.status === 600){
                        window.location.href = "/pages/admin/login.html";
                    }
                    if(xhr.status === 403){
                        window.location.href = "/403.html";
                    }
                }
            },
            'columns' : [ // data数据绑定对应列
                {"data" : null},
                {"data" : "lmId"},
                {"data" : "day"}
                // {"data" : "siteId"}
            ],
            "columnDefs" : [
                {
                    targets: 0,
                    render: function (a) {
                        return a.id + "+ "+ a.num;
                    }
                }
            ],
            // "columnDefs" : [ // 列格式化
            //     {
            //         targets: 2,
            //         render: function (a) {
            //             return a == '0'?'女':'男';
            //         }
            //     },
            //     {
            //         targets: 3,
            //         render: function (a) {
            //             if(a != ''){
            //                 var img=a.split(",");
            //                 var html="<ul>";
            //                 for(var i=0;i<img.length;i++){
            //                     html+='<span class="example2-1"><img title="'+i+'" height="70" width="70" src="'+img[i]+'"/></span>';
            //                 }
            //                 return html+"</ul>";
            //             }else{
            //                 return "";
            //             }
            //         }
            //     },
            //     {
            //         targets: 5,
            //         render: function (a) {
            //             var html = '<select id="'+a.id+'" onchange="updateTop('+a.id+','+a.top+')">';
            //             if(a.top == ''){
            //                 html += '<option selected="selected" value="0">未获奖</option>';
            //             }else{
            //                 html += '<option value="0">未获奖</option>';
            //             }
            //             if(a.top == '1'){
            //                 html += '<option selected="selected" value="1">一等奖</option>';
            //             }else{
            //                 html += '<option value="1">一等奖</option>';
            //             }
            //             if(a.top == '2'){
            //                 html += '<option selected="selected" value="2">二等奖</option>';
            //             }else{
            //                 html += '<option value="2">二等奖</option>';
            //             }
            //             if(a.top == '3'){
            //                 html += '<option selected="selected" value="3">三等奖</option>';
            //             }else{
            //                 html += '<option value="3">三等奖</option>';
            //             }
            //             html+='</select>';
            //             return html;
            //         }
            //     },
            //     {
            //         targets: 9,
            //         render: function (a) {
            //             var html = '<span class="basebutton_sm" onclick="deleteConfirm('+a.id+')">删除</span>';
            //             if(a.votes>0){
            //                 html += '<span id=s'+a.id+' class="basebutton_sm" onclick="clearVotes('+a.id+','+a.user_id+')">投票清零</span>';
            //             }
            //             return html;
            //         }
            //     }
            // ],

            'language' : {
                'lengthMenu' : "显示 _MENU_ 项结果", // 每页显示多少条
                'zeroRecords' : "没有记录！", // 没有记录时显示的内容
                'info' : "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项", // 当前页信息
                'infoEmpty' : "显示第 0 至 0 项结果，共 0 项", // 当前页信息-没有记录时
                'paginate' : {
                    'previous' : " << ",
                    'next' : " >> "
                }
            }
        });
    });
</script>
</body>
</html>
